#include "m_public.h"
#include "inner/public_for_pico.h"


/**需根据平台进行适配的公共接口 **********************************************************************************************************/
UInt32 MGetTicks(void)
{
    return to_ms_since_boot(get_absolute_time());
}


/**稳定的公共接口 ***********************************************************************************************************************/
Int32 MHex2Bin(UInt8 *out_bin, Int32 out_bin_size, const Int8 *in_hex, Int32 in_hex_len)
{
    if (out_bin == NULL || out_bin_size <= 0 || in_hex == NULL || in_hex_len <= 0)
    {
        return kErrCodeParamsErr;
    }

    Int32 ret_len = 0;

    for (Int32 idx = 0; idx < in_hex_len && ret_len < out_bin_size - 1; idx++)
    {
        UInt8 byte = in_hex[idx];

        out_bin[ret_len++] = '0' + (byte >> 4);
        out_bin[ret_len++] = '0' + (byte & 0x0f);
    }

    return ret_len;
}
